'use strict';

const proxy = require('http-proxy');

const httpProxy = proxy.createProxyServer({});

module.exports =  () => {
    return  (req, res) => {
        let route = req.routeCfg;
        let host = route.host;
        let port = route.port || 80;
        // req.headers.host = host;
        httpProxy.web(req, res, {
            host: host,
            target: req.protocol + '://' + host + ':' + port
        });
    };
};